package com.syq.play.adapter;

import java.util.List;

import com.syq.play.R;
import com.syq.play.model.FolderModel;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

public class IndexAdapter extends FolderAdapter{
	
	public IndexAdapter(Context context, List<FolderModel> listData) {
		super(context, listData);
	}
	private class ViewHolder{
		ImageView ivIcon;
		TextView tvTitle, tvNum;
	}
	public View getView(int position, View convertView, ViewGroup parent) {
		View v=convertView;
		ViewHolder vh;
		if(v==null || v.getTag()==null){
			v=mInflater.inflate(R.layout.gridview_item, null);
			vh=new ViewHolder();
			vh.ivIcon=(ImageView)v.findViewById(R.gridview_id.iv_icon);
			vh.tvTitle=(TextView)v.findViewById(R.gridview_id.tv_title);
			vh.tvNum=(TextView)v.findViewById(R.gridview_id.tv_num);
			v.setTag(vh);
		}else{
			vh=(ViewHolder)v.getTag();
		}
		FolderModel item=listData.get(position);
		vh.ivIcon.setBackgroundResource(item.getIconId());
		vh.tvTitle.setText(item.getFolderName());
		vh.tvNum.setText(item.getFileNum());
		return v;
	}
}
